<template>
    <view class="btn-action">
        <button class="btn-action-left touch" @click="goInputCode">
            <image
                class="icon-input-code"
                src="@/pages_work/static/icon/icon_input-code.png"
                @click="goInputCode"></image>
        </button>
        <button class="btn-action-right touch" @click="scan">扫码入库</button>
    </view>
</template>

<script>
import { GetBuyOrdStockOutByOutNo } from "@/service/api/buyOrder.js"
export default {
    components: {},
    props: {},
    data() {
        return {}
    },
    mounted() {},
    onShow() {},
    methods: {
        goInputCode() {
            this.easyGoTo("/pages_work/packet/purchase/input-code")
        },
        scan() {
            //扫一扫
            //#ifdef MP||APP-PLUS
            // 允许从相机和相册扫码
            //TODO 自定义扫码页面
            uni.scanCode({
                success: (res) => {
                    if (res.result) {
                        // uni.showToast({
                        // 	title: "扫码结果:" + res.result,
                        // 	icon: 'none',
                        // 	duration: 2000
                        // });
                        this.submitFn(res.result)
                    }
                },
            })
            //#endif
        },
        submitFn(code) {
            let param = {
                keyWord: code,
            }
            let path = "?keyWord=" + code
            GetBuyOrdStockOutByOutNo(param, path).then((res) => {
                if (res.State == 1) {
                    let data = encodeURIComponent(JSON.stringify(res.Data))
                    this.easyGoTo("/pages_work/packet/purchase/confirm?keyWord=" + code + "&data=" + data)
                } else {
                    this.easyToast(res.Msg)
                }
            })
        },
    },
}
</script>

<style lang="scss"></style>
